<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jacobi Theta Function θ2</title>
<link rel="stylesheet" href="../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../jacobi_theta.html" title="Jacobi Theta Functions">
<link rel="prev" href="jacobi_theta1.html" title="Jacobi Theta Function θ1">
<link rel="next" href="jacobi_theta3.html" title="Jacobi Theta Function θ3">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="jacobi_theta1.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../jacobi_theta.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="jacobi_theta3.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="math_toolkit.jacobi_theta.jacobi_theta2"></a><a class="link" href="jacobi_theta2.html" title="Jacobi Theta Function θ2">Jacobi Theta
      Function θ<sub>2</sub></a>
</h3></div></div></div>
<h5>
<a name="math_toolkit.jacobi_theta.jacobi_theta2.h0"></a>
        <span class="phrase"><a name="math_toolkit.jacobi_theta.jacobi_theta2.synopsis"></a></span><a class="link" href="jacobi_theta2.html#math_toolkit.jacobi_theta.jacobi_theta2.synopsis">Synopsis</a>
      </h5>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">jacobi_theta</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span> <span class="special">{</span>
    <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span>
    <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">jacobi_theta2</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">U</span> <span class="identifier">q</span><span class="special">);</span>

    <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">&gt;</span>
    <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">jacobi_theta2</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">U</span> <span class="identifier">q</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;);</span>

    <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span>
    <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">jacobi_theta2tau</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">U</span> <span class="identifier">tau</span><span class="special">);</span>

    <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Policy</span><span class="special">&gt;</span>
    <a class="link" href="../result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">jacobi_theta2tau</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">U</span> <span class="identifier">tau</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Policy</span><span class="special">&amp;);</span>
<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.jacobi_theta.jacobi_theta2.h1"></a>
        <span class="phrase"><a name="math_toolkit.jacobi_theta.jacobi_theta2.description"></a></span><a class="link" href="jacobi_theta2.html#math_toolkit.jacobi_theta.jacobi_theta2.description">Description</a>
      </h5>
<p>
        The functions calculate the value of second <a class="link" href="jacobi_theta_overview.html" title="Overview of the Jacobi Theta Functions">Jacobi
        Theta function</a>, parameterized either in terms of the nome <span class="emphasis"><em>q</em></span>:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../equations/jacobi_theta2.svg"></span>

        </p></blockquote></div>
<p>
        Or in terms of an imaginary τ:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../equations/jacobi_theta2tau.svg"></span>

        </p></blockquote></div>
<p>
        The nome <span class="emphasis"><em>q</em></span> is restricted to the domain (0, 1), returning
        the result of <a class="link" href="../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
        otherwise. The following graph shows the theta function at various values
        of <span class="emphasis"><em>q</em></span>:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../graphs/jacobi_theta2.svg" align="middle"></span>

        </p></blockquote></div>
<p>
        The final <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
        be used to control the behaviour of the function: how it handles errors,
        what level of precision to use etc. Refer to the <a class="link" href="../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">policy
        documentation for more details</a>.
      </p>
<h5>
<a name="math_toolkit.jacobi_theta.jacobi_theta2.h2"></a>
        <span class="phrase"><a name="math_toolkit.jacobi_theta.jacobi_theta2.accuracy"></a></span><a class="link" href="jacobi_theta2.html#math_toolkit.jacobi_theta.jacobi_theta2.accuracy">Accuracy</a>
      </h5>
<p>
        The following <a class="link" href="../ulps_plots.html" title="ULPs Plots">ULPs plot</a> is
        representative, fixing <span class="emphasis"><em>q</em></span>=0.5 and varying <span class="emphasis"><em>x</em></span>
        from 0 to 2π:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../graphs/jacobi_theta2_float.svg" align="middle"></span>

        </p></blockquote></div>
<p>
        The envelope represents the function's <a href="https://en.wikipedia.org/wiki/Condition_number#One_variable" target="_top">condition
        number</a>. Note that relative accuracy degenerates periodically near
        θ<sub>2</sub>=0.
      </p>
<p>
        Fixing <span class="emphasis"><em>x</em></span>=0.4 and varying <span class="emphasis"><em>q</em></span>, the
        ULPs plot looks like:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../graphs/jacobi_theta2q_float.svg" align="middle"></span>

        </p></blockquote></div>
<p>
        Accuracy tends to degenerate near <span class="emphasis"><em>q</em></span>=1 (small τ).
      </p>
<h5>
<a name="math_toolkit.jacobi_theta.jacobi_theta2.h3"></a>
        <span class="phrase"><a name="math_toolkit.jacobi_theta.jacobi_theta2.implementation"></a></span><a class="link" href="jacobi_theta2.html#math_toolkit.jacobi_theta.jacobi_theta2.implementation">Implementation</a>
      </h5>
<p>
        The <span class="emphasis"><em>q</em></span> parameterization is implemented using the τ parameterization,
        where τ=-log(<span class="emphasis"><em>q</em></span>)/π.
      </p>
<p>
        If τ is greater than or equal to 1, the summation above is used as-is. However
        if τ &lt; 1, the following identity <a href="https://dlmf.nist.gov/20.7#viii" target="_top">DLMF
        20.7.31</a> is used, defining τ'=-1/τ:
      </p>
<div class="blockquote"><blockquote class="blockquote"><p>
          <span class="inlinemediaobject"><img src="../../../equations/jacobi_theta2_imaginary.svg"></span>

        </p></blockquote></div>
<p>
        This transformation of variables ensures that the function will always converge
        in a small number of iterations.
      </p>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="jacobi_theta1.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../jacobi_theta.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="jacobi_theta3.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
